package org.bigdata.framework.admin.web.util;

import java.net.InetAddress;

import org.bigdata.framework.core.model.Log;
import org.bigdata.framework.core.protocol.IBaseService;
import org.springframework.beans.factory.annotation.Autowired;


public class LogSave {
	@Autowired
	private IBaseService baseService;
		//公共日常记录
	public void Log(Integer createUserId,String logType,String classesId,String dataId,String logText,Integer logStatus) throws Exception{
		//获得本机IP 
		InetAddress addr = InetAddress.getLocalHost();   
		String createIpAddress=addr.getHostAddress();  
		//获得时间
		String createTime = DateUtils.getDateTime();
		
		Log log=new Log();
		log.setCreateTime(createTime);
		log.setCreateUserId(createUserId);
		log.setCreateIpAddress(createIpAddress);
		log.setLogType(logType);
		log.setLogText(logText);
		log.setLogStatus(logStatus);
			
		if(classesId !=null){
			log.setClassesId(classesId);
		}
		if(dataId !=null){
			log.setDataId(dataId);
		}
		Log l=baseService.saveLog(log);
		System.out.println(l);
	}
}
